﻿@{
    ViewBag.Title = "登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@Styles.Render("~/Content/css/disablePage")
<nav class="disable_mod_nav">
    <div class="lay_left">
        <a class="nav_back" onclick="turnBack()"><img src="/images/TurnBack.png"></a>
        <span>登录</span>
    </div>
</nav>
<div class="LoginHead"><a><img src="~/images/icon_normal.png" class="HeadImg"></a></div>
<section class="LogInCon">
    <div class="alert alert-warning" style="display:none" role="alert">
        <strong></strong>
    </div>
    <div class="LogInName LogInImg">
        <img src="~/images/LogName.png">
        <input type="tel" id="userName" placeholder="11位手机号码">
    </div>
    <div class="LogInName LogInWord LogInImg">
        <img src="~/images/LogWord.png">
        <input type="password" id="passWord" placeholder="请输入密码">
        <a class="LogInDel"><img src="~/images/LogInDel.png"></a>
    </div>
    <input type="button" value="登录" onclick="login()" class="LogInBtn">
    <div class="LogInA">
        @Html.ActionLink("注册账号", "Register", "User")
        @Html.ActionLink("忘记密码", "ResetPassword", "User")
    </div>
</section>

<script>
    function login() {
        var userName = $("#userName").val();
        var passWord = $("#passWord").val();
        if (!Val.isMobile(userName)) {
            $("#userName").focus();
            $(".alert").attr("style", "display:block");
            $(".alert strong").html("请输入正确的手机号！");
        } else if (passWord.length == 0) {
            $("#passWord").focus();
            $(".alert").attr("style", "display:block");
            $(".alert strong").html("请输入密码！");
        } else {
            var data = { 'uid': userName, 'pass_word': passWord };
            var command = "login";
            doAjax(data, command, function (msg) {
                if (msg.result == "0") {
                    UserInfoMgr.logIn(userName, passWord, msg.unpicked_order_num, msg.score, msg.scale2cash);
                    window.location.href = '@ViewBag.url';
                } else {
                    $("#userName").focus();
                    $(".alert").attr("style", "display:block");
                    $(".alert strong").html("登录失败，请重试！");
                }
            });
        }
    }
    function turnBack() {
        window.location.href = '@Url.Content("~/")' + 'User/Index';
    }
</script>